/**
 * @file Threadpool.h
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2022-04-05
 *
 * @copyright Copyright (c) 2022
 *
 */

#pragma once

#include "TaskQueue.h"
#include <functional>
#include <vector>

namespace wd
{
class Thread;

class Threadpool
{
  public:
    typedef std::function<void()> Task;
    Threadpool(size_t threadsNum, size_t bufNum);
    ~Threadpool();

    void start();
    void stop();

    void addTask(Task task);

  private:
    void threadFunc();
    Task getTask();

  private:
    size_t threadsNum_;
    std::vector<Thread *> vecThreads_;
    TaskQueue buf_;
    bool isExit_;
};

} // end of namespace wd
